package com.blog.admin.mapper.apiMapper;

import com.blog.admin.vo.BlogClassifyVO;
import com.blog.admin.vo.BlogLinkVO;
import com.blog.admin.vo.BlogResourcesVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author tangqj
 * @Description 关于本站模块部分接口
 * @create 2020/3/12 14:35
 */
public interface AboutMapper {

    /**
     *  获取所有友情链接
     * @return
     */
    @Select("select * from blog_link order by create_time desc")
    List<BlogLinkVO> getBlogLink();

    /**
     *  获取所有分类及其关键字
     * @return
     */
    @Select("select * from blog_classify order by create_time desc")
    List<BlogClassifyVO> getBlogClassify();

    /**
     *  获取点点滴滴
     * @return
     */
    @Select("select content,create_time from blog_resources where resource_type = -1 order by create_time desc")
    List<Map<String,Object>> getBlogResourcesDD();

    /**
     *  获取资源下载
     * @return
     */
    @Select("<script>  " +
            "select a.title,a.author,a.content,a.abstract_content,a.thumbimg,sui.realname from blog_resources a\n" +
            "        left join sys_user b on a.pk_user = b.id\n" +
            "        left join sys_user_information sui on a.pk_user = sui.pk_user where  a.resource_type != -1\n" +
            "            <if test=\"title !=null and title !=''\">\n" +
            "                and a.title like \"%\"#{title}\"%\"\n" +
            "            </if>\n" +
            "            <if test=\"id !=null and id !=''\">\n" +
            "                and a.id = #{id}\n" +
            "            </if>\n" +
            "            <if test=\"resourceType != null and resourceType != ''\">\n" +
            "                and a.resource_type = #{resourceType}\n" +
            "            </if>\n" +
            "        order by a.create_time desc" +
            "</script>")
    List<Map<String,Object>> getBlogResources(@Param("id") String id, @Param("resourceType") String resourceType, @Param("title") String title);

}
